/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.impexp.model;

import cn.ekuma.impexp.FieldGenerator;
import com.openbravo.data.loader.TableDefinition;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class ImpExpTableDefinition  extends AbstractImpExpTableDefinition{

    public ImpExpTableDefinition(TableDefinition baseTable) {
        super(baseTable);
    }

    public Object[] getData(int rowIndex) {
        ImpExpRowDefinition row = getRow(rowIndex);
        Object[] rowdata = row.getDatas();
        if (row.getState() == ImpExpRowDefinition.STATE_Import_Insert) {
            for (int i = 0; i < getFieldIndexs().length; i++) {
                if (fieldGenerators.containsKey(i)) {
                    FieldGenerator generator = fieldGenerators.get(i);
                    rowdata[i] = generator.getNext();
                }
            }
        }
        return rowdata;
    }

    public int[] getFieldIndexs() {
        return filterIndexs;
    }

    public int[] getUpdateFieldIndexs() {
    	return filterIndexs;
        /**List<Integer> s1 = new ArrayList<Integer>();
        List<Integer> s2 = new ArrayList<Integer>();
        for (int i = 0; i < filterIndexs.length; i++) {
            s1.add(filterIndexs[i]);
        }
        for (int i = 0; i < updateIgnoreIndexs.length; i++) {
            s2.add(updateIgnoreIndexs[i]);
        }
        s1.removeAll(s2);
        int[] updateIndexs = new int[s1.size()];
        for (int i = 0; i < s1.size(); i++) {
            updateIndexs[i] = s1.get(i).intValue();
        }
        return updateIndexs;*/
    }
    
    
    public void setFieldIndexs(int[] inds) {
        filterIndexs=inds;
    } 
}
